using System;
using System.Collections.Generic;
using UnityEngine;

namespace Yoozoo.Gameplay.City
{
    [Serializable]
    public class RoomFeature
    {
        public int RoomID;
        public string RoomLuaFileName;

        public string Name;    // 备注名
    }
    
    [Serializable]
    public class HudFeature
    {
        public string EnumName;
        public int HudID;
        public string HudLuaFileName;
        public string HudPrefabPath;

        public string Name;    // 备注名
    }
    
    [Serializable]
    public class CityFeatureConfig
    {
        public List<RoomFeature> RoomFeatures;

        public List<HudFeature> HudFeatures;

        private Dictionary<int, HudFeature> _hudFeatureMap;

        public HudFeature GetHudFeature(int hudType)
        {
            if (_hudFeatureMap == null || _hudFeatureMap.Count == 0)
            {
                _hudFeatureMap = new Dictionary<int, HudFeature>();
                foreach (var hudFeature in HudFeatures)
                {
                    _hudFeatureMap[hudFeature.HudID] = hudFeature;
                }    
            }

            HudFeature hf = null;
            _hudFeatureMap.TryGetValue(hudType, out hf);
            return hf;
        }

        public static CityFeatureConfig Json2Config(TextAsset json)
        {
            return JsonUtility.FromJson<CityFeatureConfig>(json.text);
        }
        
    }
}